*************************
*** REGRESSION TABLES ***
*************************

use "${here}MICE2.dta", clear

keep genderid sexualid4 education income born_outside_canada indigenous racialized mother_tongue4 ///
	partyid voteintention votechoice ///
	immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy international_trade government_intervention income_inequality wealth_gap ///
	age4 pt user_language cps21_weight_general_all ///
	_mi _mj

mi import ice, automatic clear

*** EXAMINE RELATIONSHIPS AMONG ISSUE ATTITUDES
corr immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy international_trade government_intervention income_inequality wealth_gap if _mi_m ~= 0
alpha immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy government_intervention income_inequality wealth_gap if _mi_m ~= 0
factor immigration refugees jobs_vs_environment_pes family_values bilingualism equal_rights immigrant_integration immigrant_jobs abortion conversion_therapy government_intervention income_inequality wealth_gap if _mi_m ~= 0

*** GENERATE LEFT-RIGHT SCALE
gen left = (immigration + refugees + jobs_vs_environment_pes + family_values + bilingualism + equal_rights + immigrant_integration + immigrant_jobs + abortion + conversion_therapy + government_intervention + income_inequality + wealth_gap) / 13

*** GENERATE IMMIGRATION SCALE
gen immigration_scale = (immigration + refugees + immigrant_integration + immigrant_jobs) / 4
alpha immigration refugees immigrant_integration immigrant_jobs
factor immigration refugees immigrant_integration immigrant_jobs

*** GENERATE REDISTRIBUTION/INEQUALITY SCALE
gen redistribution_scale = (income_inequality + wealth_gap) / 2
alpha income_inequality wealth_gap

*** GENERATE TRADITIONALISM SCALE
gen traditionalism_scale = (family_values + equal_rights) / 2
alpha family_values equal_rights

*** GENERATE VECTOR OF DUMMY VARIABLES FOR PARTY IDENTIFICATION
tab partyid, gen(pid_)

*** GENERATE VECTOR OF DUMMY VARIABLES FOR VOTE CHOICE
tab votechoice, gen(vote_)

*** RECODE INCOME
recode income (1=2)
gen income7 = income - 1
label variable income7 "Income"

*** LABEL VARIABLES AND VALUE LABELS
label variable education "Education"
label define educations 1 "No High School" 2 "High School Diploma" 3 "Some College/ University" 4 "Bachelor's or Higher"
label values education educations

label variable income "Income"

label define sexualids 1 "Straight" 2 "Gay/Lesbian" 3 "Bisexual" 4 "Other Sexual Identity"
label values sexualid4 sexualids

label define countries2 0 "Born in Canada" 1 "Born Outside Canada"
label values born_outside_canada countries2

label variable indigenous "Indigenous"
label define indig 0 "Not Indigenous" 1 "Indigenous"
label values indigenous indig

label variable racialized "Racialized"
label define rac 0 "Not Racialized" 1 "Racialized"
label values racialized rac

label define mothertongues 1 "Mother Tongue: English" 2 "Mother Tongue: French" 3 "Mother Tongue: Both" 4 "Mother Tongue: Neither"
label values mother_tongue4 mothertongues

label define pts 1 "Province: NL" 2 "Province: NS" 3 "Province: PE" 4 "Province: NB" 5 "Province: QC" 6 "Province: ON" 7 "Province: MB" 8 "Province: SK" 9 "Province: AB" 10 "Province: BC"
label values pt pts

label define ct 0 "No Ban" 1 "Conversion Therapy Ban" 
label values conversion_therapy ct

label variable immigration_scale "Immigration Scale"
label variable redistribution_scale "Economic Inequality Scale"
label variable left "Left-Right Scale"
label variable family_values "Family Values"
label variable equal_rights "Equal Rights"
label variable jobs_vs_environment "Jobs vs. Environment"
label variable abortion "Abortion"
label variable bilingualism "Bilingualism"
label variable government_intervention "Government Intervention"

*** LIBERAL PARTY IDENTIFICATION TABLES
estimates clear

mi estimate, post: logit pid_1 i.genderid [pweight = cps21_weight_general_all]
estimates store A

mi estimate, post: logit pid_1 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
estimates store B

mi estimate, post: logit pid_1 i.genderid i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store C

mi estimate, post: logit pid_1 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
estimates store D

mi estimate, post: logit pid_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
estimates store E

mi estimate, post: logit pid_1 i.genderid c.left [pweight = cps21_weight_general_all]
estimates store F

mi estimate, post: logit pid_1 i.genderid i.conversion_therapy i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store G

mi estimate, post: logit pid_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store H

mi estimate, post: logit pid_1 i.genderid c.left i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store I

estout A B C using "LiberalPartyID1.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout D E F using "LiberalPartyID2.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout G H I using "LiberalPartyID3.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace
	
*** CONSERVATIVE PARTY IDENTIFICATION TABLES
estimates clear

mi estimate, post: logit pid_2 i.genderid [pweight = cps21_weight_general_all]
estimates store A

mi estimate, post: logit pid_2 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
estimates store B

mi estimate, post: logit pid_2 i.genderid i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store C

mi estimate, post: logit pid_2 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
estimates store D

mi estimate, post: logit pid_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
estimates store E

mi estimate, post: logit pid_2 i.genderid c.left [pweight = cps21_weight_general_all]
estimates store F

mi estimate, post: logit pid_2 i.genderid i.conversion_therapy i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store G

mi estimate, post: logit pid_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store H

mi estimate, post: logit pid_2 i.genderid c.left i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store I

estout A B C using "ConservativePartyID1.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout D E F using "ConservativePartyID2.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout G H I using "ConservativePartyID3.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace
	
*** NDP PARTY IDENTIFICATION TABLES
estimates clear

mi estimate, post: logit pid_3 i.genderid [pweight = cps21_weight_general_all]
estimates store A

mi estimate, post: logit pid_3 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
estimates store B

mi estimate, post: logit pid_3 i.genderid i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store C

mi estimate, post: logit pid_3 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
estimates store D

mi estimate, post: logit pid_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
estimates store E

mi estimate, post: logit pid_3 i.genderid c.left [pweight = cps21_weight_general_all]
estimates store F

mi estimate, post: logit pid_3 i.genderid i.conversion_therapy i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store G

mi estimate, post: logit pid_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store H

mi estimate, post: logit pid_3 i.genderid c.left i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store I

estout A B C using "NDPPartyID1.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout D E F using "NDPPartyID2.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout G H I using "NDPPartyID3.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace
	
*** LIBERAL VOTE CHOICE TABLES
estimates clear

mi estimate, post: logit vote_1 i.genderid [pweight = cps21_weight_general_all]
estimates store A

mi estimate, post: logit vote_1 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
estimates store B

mi estimate, post: logit vote_1 i.genderid i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store C

mi estimate, post: logit vote_1 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
estimates store D

mi estimate, post: logit vote_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
estimates store E

mi estimate, post: logit vote_1 i.genderid c.left [pweight = cps21_weight_general_all]
estimates store F

mi estimate, post: logit vote_1 i.genderid i.conversion_therapy i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store G

mi estimate, post: logit vote_1 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store H

mi estimate, post: logit vote_1 i.genderid c.left i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store I

estout A B C using "LiberalVoteChoice1.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout D E F using "LiberalVoteChoice2.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout G H I using "LiberalVoteChoice3.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace
	
*** CONSERVATIVE VOTE CHOICE TABLES
estimates clear

mi estimate, post: logit vote_2 i.genderid [pweight = cps21_weight_general_all]
estimates store A

mi estimate, post: logit vote_2 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
estimates store B

mi estimate, post: logit vote_2 i.genderid i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store C

mi estimate, post: logit vote_2 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
estimates store D

mi estimate, post: logit vote_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
estimates store E

mi estimate, post: logit vote_2 i.genderid c.left [pweight = cps21_weight_general_all]
estimates store F

mi estimate, post: logit vote_2 i.genderid i.conversion_therapy i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store G

mi estimate, post: logit vote_2 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store H

mi estimate, post: logit vote_2 i.genderid c.left i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store I

estout A B C using "ConservativeVoteChoice1.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout D E F using "ConservativeVoteChoice2.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout G H I using "ConservativeVoteChoice3.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace
	
*** NDP VOTE CHOICE TABLES
estimates clear

mi estimate, post: logit vote_3 i.genderid [pweight = cps21_weight_general_all]
estimates store A

mi estimate, post: logit vote_3 i.genderid i.age4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 [pweight = cps21_weight_general_all]
estimates store B

mi estimate, post: logit vote_3 i.genderid i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store C

mi estimate, post: logit vote_3 i.genderid i.conversion_therapy [pweight = cps21_weight_general_all]
estimates store D

mi estimate, post: logit vote_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_interventio [pweight = cps21_weight_general_all]
estimates store E

mi estimate, post: logit vote_3 i.genderid c.left [pweight = cps21_weight_general_all]
estimates store F

mi estimate, post: logit vote_3 i.genderid i.conversion_therapy i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store G

mi estimate, post: logit vote_3 i.genderid i.conversion_therapy immigration_scale redistribution_scale family_values equal_rights jobs_vs_environment bilingualism abortion government_intervention i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store H

mi estimate, post: logit vote_3 i.genderid c.left i.age4 i.education c.income i.sexualid4 i.born_outside_canada i.indigenous i.racialized i.mother_tongue4 i.pt [pweight = cps21_weight_general_all]
estimates store I

estout A B C using "NDPVoteChoice1.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout D E F using "NDPVoteChoice2.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace

estout G H I using "NDPVoteChoice3.tex", cells(b(star fmt(2)) ///
	se(par fmt(2))) ///
	stats(N_mi M_mi, labels("Observations" "Imputations")) ///
	starlevels(* 0.10 ** 0.05 *** 0.01) ///
	label ///
	legend ///
	varlabels(_cons Constant) ///
	style(tex) ///
	replace
	